package com.blogspot.security.dao.impl;

import java.io.Serializable;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.hibernate.SessionFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.blogspot.security.dao.UserRegisterDao;
import com.blogspot.security.domain.ApplicationUser;

@Repository
public class UserRegisterDaoImpl implements UserRegisterDao  , Serializable {
	private Logger logger = LoggerFactory.getLogger(UserRegisterDaoImpl.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
    @PersistenceContext
    EntityManager em;
    
    protected HibernateTemplate template;
    
    @Autowired
    public void setSessionFactory(SessionFactory sessionFactory)
    {
      template = new HibernateTemplate(sessionFactory);
    }
    
	public EntityManager getEntityManager() {
		// TODO Auto-generated method stub
		return em;
	}
    
    public void insertApplicationUser(ApplicationUser user) {
    	logger.error("Allan Sung Test : " + user.getUserName());
    	template.saveOrUpdate(user);
    }
}
